package com.amat0urheu.dao;

import com.amat0urheu.pojo.CloudPojo.VMservice;
import com.amat0urheu.pojo.ExperimentScene;
import com.amat0urheu.pojo.race.FlagLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/*
 *@Auther:amaT0ur
 *@create:2023-11-18
 */
@Mapper
public interface ExperimentSceneMapper extends BaseMapper<ExperimentSceneMapper> {
    @Select("select b.Id, a.eid as eId ,ename ,c.Id as sId,scene from mc_experiment a , mc_experiment_scene b,mc_scene c where a.eid=b.eid and b.sId=c.Id")
    List<ExperimentScene> selectExperimentScenePage();
    @Delete("delete  from mc_experiment_scene where id= #{id}")
    int removeExperimentScene(Integer id);
    @Insert("insert mc_experiment_scene values (null,#{eid} ,#{sId})")
    int  insertExperimentScene(Integer eid, Integer sId);
    @Update("update mc_experiment_scene set sId=#{experimentScene.sId} where Id=#{experimentScene.Id} and eId=#{experimentScene.eId}")
    int updateExperimentScene(@Param("experimentScene") ExperimentScene experimentScene);
    @Select("select b.Id, a.eid as eId ,ename ,c.Id as sId,scene from mc_experiment a , mc_experiment_scene b,mc_scene c where a.eid=b.eid and b.sId=c.Id and   ${key} like #{value}")
    List<ExperimentScene> searchExperimentAndSceneForAdmin(String key, String value);
    @Select("select * from mc_vm  where race is null  and ${key} like #{value} order by ID asc ")
    List<VMservice> searchRaceVmForAdmin(String key, String value);
    @Select("select experiment from mc_vm  where race is  null and experiment is not null   group by experiment  ")
    List<String> getAllExperiments();
    @Select("SELECT COUNT(DISTINCT proxyNum) AS NumOfProxyNum FROM mc_vm WHERE experiment = #{experiment} AND deadTime > CURRENT_TIMESTAMP AND type NOT LIKE '%client%'")
    int getVmSumofExperiment(String experiment);
    @Select("SELECT COUNT(DISTINCT proxyNum) AS NumOfProxyNum FROM mc_vm WHERE experiment = #{experiment} AND deadTime > CURRENT_TIMESTAMP AND type NOT LIKE '%client%'  and user is not null")
    int getVmUsingofExperiment(String experiment);
}
